package com.yonyou.crm.bpub.template.service;

import java.util.*;

import org.springframework.beans.factory.annotation.Autowired;

import com.yonyou.crm.bpub.template.entity.*;
import com.yonyou.crm.common.enumeration.entity.EnumVO;
import com.yonyou.crm.common.enumeration.rmitf.IEnumRmService;

abstract public class BaseTemplates {
	
	@Autowired
	IEnumRmService enumService;
	
	abstract public ArrayList<TemplatesHeaderVO> getHeader();
	abstract public ArrayList<TemplatesBodyVO> getBody();
	abstract public ArrayList<TemplatesTriggerVO> getTrigger();
	abstract public ArrayList<TemplatesFilterVO> getFilter();
	
	public ArrayList<TemplatesEnumVO> getEnumList(String code) {
		ArrayList<TemplatesEnumVO> res = new ArrayList<TemplatesEnumVO>();
		String[] codes = {code};
		Map<String, List<EnumVO>> enumList = enumService.getEnumByCodes(codes);
		List<EnumVO> list =  enumList.get(code);
		for(int i = 0; i < list.size(); i++) {
			EnumVO item = list.get(i);
			TemplatesEnumVO enumItem = new TemplatesEnumVO(item.getValue().toString(), item.getName());
			res.add(enumItem);
		}
		return res;
	}

}
